package org.car.word.service.util;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

/**
 * @author szw
 * @ClassName: MyHealthIndicator
 * @Description: 自定义项目监测帮助类》》自定义健康端点
 * @date 2019年2月16日
 */
@Component("my1")
public class MyHealthIndicator implements HealthIndicator {

    /**
     * 自定义版本号
     */
    private static final String VERSION = "v1.0.0";

    /**
     * 实现HealthIndicator接口，根据自己的需要判断返回的状态是UP还是DOWN
     */
    @Override
    public Health health() {
        int code = check();
        if (code != 0) {

            Health.down().withDetail("code", code).withDetail("version", VERSION).build();
        }
        return Health.up().withDetail("code", code).withDetail("version", VERSION).up().build();
    }

    private int check() {
        return 0;
    }

}
